// 使用 Mock
var Mock = require('mockjs')

let city = require('./city.json')
let menu = require('./menu.json')
let store = require('./store.json')
let indexListData = require('./index-list.json')

let sellerData = require('./seller.json')

// 拓展mockjs
Mock.Random.extend({
    phone: function () {
        var phonePrefixs = ['182', '136', '189'] // 前缀
        return this.pick(phonePrefixs) + Mock.mock(/\d{8}/) //Number()
    }
})

Mock.mock(RegExp('/api/getStore.*'),"get",function(options){
    console.log(options);
    return store;
})

Mock.mock('/api/getMenu','get',menu)

Mock.mock("/api/getCities",'get',{
    status:0,
    msg:'',
    data:{
        cities:city
    }
})

Mock.mock("/api/getVerificationCode", "get", {
    status: 0,
    msg: '生成成功',
    data: {
        'num|100000-999999': 1
    }
})

Mock.mock('/api/labelMap','get',{ 
    status:200,
    msg:'success',
    data:{
        data:{
            '0':'家',
            '1':'学校',
            '2':'其他'
        }
    }
})

Mock.mock("/login", "post", function (options) {
    return {
        status: 1,
        msg: "登录成功",
        data: {
            userInfo: Mock.mock({
                'name': '@cname',
                'pwd': '123456',
                'star|1-20': 1,
                'phone': '@phone',
                'common_address': [],
                'avatar': 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2620306848,1106594030&fm=26&gp=0.jpg'
            })
        }
    }
})

Mock.mock('/api/indexList','get',{ 
    code:0,
    msg:'success',
    data: indexListData
})
Mock.mock('/api/seller','get',{ 

    // 0 -> 请求成功
    code: 0,
    data: sellerData.seller

})
Mock.mock('/api/goods','get',{ 

    // 0 -> 请求成功
    code: 0,
    data: sellerData.goods

})
Mock.mock('/api/ratings','get',{ 

    // 0 -> 请求成功
    code: 0,
    data: sellerData.ratings

})

